package utils.common;

import utils.X;

import java.util.Collection;

/**
 * 对象工具
 * @author chao
 * @since 2015/1/12
 */
public class ObjectUtil {

    /**
     * 如果有任意对象为空，返回true
     * @param objs
     * @return
     */
    public boolean isAnyEmpty(Object... objs){
        for(Object obj: objs){
            if(isEmpty(obj)){
                return true;
            }
        }
        return false;
    }

    public boolean isEmpty(Object obj){
        if(obj == null){
            return true;
        }
        if(obj instanceof Collection){
            return X.collection.isEmpty((Collection) obj);
        }
        if(obj instanceof String){
            return StringUtil.isEmpty((String) obj);
        }
        return false;
    }

    public boolean isNotEmpty(Object obj){
        return !isEmpty(obj);
    }

}
